* Most graphs following the same specification/estimation are run in loop, to search a specific figure/table from the paper search for e.g. "figure 1 panel a", "table 1 panel b", "figure s1", "table s1"

* PREAMBLE
clear all
set more off
set graphics off
capture log close
set maxvar 20000

* DIRECTORIES
cd ..

* PACKAGES
*ssc install coefplot
*ssc install reghdfe /* update if old version */
*ssc install ivreghdfe
*ssc install binscatterhist
*ssc install binscatter
*ssc install addplot
*ssc install lgraph

* DATA LOAD
use data/data_zipcode.dta

* VARIOUS GLOBALS FOR GRAPHS FORMATTING AND REGRESSIONS
if "run"=="run"{
	
* dates period
global dates_coefplot_mobility_sf "_21946 _21947 _21948 _21949 _21950 _21951 _21952 _21953 _21954 _21955 _21956 _21957 _21958 _21959 _21960 _21961 _21962 _21963 _21964 _21965 _21966 _21967 _21968 _21969 _21970 _21971 _21972 _21973 _21974 _21975 _21976 _21977 _21978 _21979 _21980 _21981 _21982 _21983 _21984 _21985 _21986 _21987 _21988 _21989 _21990 _21991 _21992 _21993 _21994 _21995 _21996 _21997 _21998 _21999 _22000 _22001 _22002 _22003 _22004 _22005 _22006 _22007 _22008 _22009 _22010 _22011 _22012 _22013 _22014 _22015 _22016 _22017 _22018 _22019 _22020 _22021 _22022 _22023 _22024 _22025 _22026 _22027 _22028 _22029 _22030 _22031 _22032 _22033 _22034 _22035"
global x_line_sf "xline(0.511 0.665 0.830 0.983 1.170 1.324 1.489, lpattern(dot) lwidth(1) lcolor(gray)) xlabel(0.511 "February 1st" 0.665 "February 15th" 0.830 "March 1st" 0.983 "March 15th" 1.170 "April 1st" 1.324 "April 15th" 1.489 "April 30th")"
global x_line_multi "xline(1 15 30 44 60 74 89, lpattern(dot) lwidth(1) lcolor(gray)) xlabel(1 "February 1st" 15 "February 15th" 30 "March 1st" 44 "March 15th" 60 "April 1st" 74 "April 15th" 89 "April 30th")"

* first stage
global general_options_fs_fxnc " graphregion(fcolor(white))  legend(off) ytitle("Fox News Viewership") xtitle("Fox News Channel Position (Standardized)")  color(teal) lcolor(maroon) "
global general_options_fs_cnn " graphregion(fcolor(white))  legend(off) ytitle("CNN Viewership") xtitle("CNN Position (Standardized)")  color(teal) lcolor(maroon) "
global general_options_fs_msnbc " graphregion(fcolor(white))  legend(off) ytitle("MSNBC Viewership") xtitle("MSNBC Position (Standardized)")  color(teal) lcolor(maroon) "

* reduced form
global general_options_reduced "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Mobility (RF)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_reduced_p "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Total Expenditure (USD)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_reduced_ratioc "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Infection Rate (RF)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_reduced_ratiod"graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Deaths Per Capita (RF)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global other_options_reduced " graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on `y' (RF)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options2 " graphregion(margin(3 6 3 3)) graphregion(fcolor(white)) vertical legend(off) ytitle("Total Expenditure (USD)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(medsmall) symbol(plus) color(maroon)"	

* OLS
global general_options_ols "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Mobility (OLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_ols_ratioc "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Infection Rate (OLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_ols_ratiod "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Deaths Per Capita (OLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global other_options_ols "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on `y' (OLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"

* 2SLS
global general_options"graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Mobility (2SLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_ratioc "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Mobility (2SLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_ratiod "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on Mobility (2SLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global other_options_iv "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Effect on `y' (2SLS)") yline(0, lpattern(dash) lcolor(gray)) xsize(8)  ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"
global general_options_p "graphregion(margin(3 6 3 3))  graphregion(fcolor(white)) vertical legend(off) ytitle("Total Expenditure (USD)") yline(0, lpattern(dash) lcolor(gray)) xsize(8) xtitle("Date") ciopts(color(teal)) msize(small) symbol(circle_hollow) color(maroon)"

* iteration vars
global outcomes_pick "tot_expgroc tot_expcovid_prod"
global outcomes_pick2 "sd_sf_dist_fr_home sd_sf_median_nohome_time"


* globals for other networks controls
global other_ch_fxnc "msnbc cnn"
global other_ch_cnn "msnbc fxnc"
global other_ch_msnbc "fxnc cnn"

* controls
global full_controls1 "pop_dens landarea age_imb pct_food_stamps pct_nohs pct_college med_white med_black pct_male"

}
*

* DECADATA SHOPPING DATA
* figure 1 panel c, figure s14, table s6
global decadata=1
if ${decadata}==1{
foreach pre in sd_ {
	foreach cl in state_fips {
		foreach network in fxnc {
			foreach y of global outcomes_pick  {
				cap drop _est*				
					forvalues date=21946/22035 {
					cap qui reghdfe `pre'`y'_w_`date' `network' [aweight=pop], absorb(state_fips one##c.(sd_`y'_j20 $full_controls1)) cluster(`cl')
					cap eststo _`date'
					}
				macro drop options
				coefplot (_21946, color(white%1) ciopts(color(white%1)) ) _21947 (_21948, color(white%1) ciopts(color(white%1)) ) (_21949, color(white%1) ciopts(color(white%1)) ) (_21950, color(white%1) ciopts(color(white%1)) ) (_21951, color(white%1) ciopts(color(white%1)) ) (_21952, color(white%1) ciopts(color(white%1)) ) (_21953, color(white%1) ciopts(color(white%1)) ) _21954 (_21955, color(white%1) ciopts(color(white%1)) ) (_21956, color(white%1) ciopts(color(white%1)) ) (_21957, color(white%1) ciopts(color(white%1)) ) (_21958, color(white%1) ciopts(color(white%1)) ) (_21959, color(white%1) ciopts(color(white%1)) ) (_21960, color(white%1) ciopts(color(white%1)) ) _21961 (_21962, color(white%1) ciopts(color(white%1)) ) (_21963, color(white%1) ciopts(color(white%1)) ) (_21964, color(white%1) ciopts(color(white%1)) ) (_21965, color(white%1) ciopts(color(white%1)) ) (_21966, color(white%1) ciopts(color(white%1)) ) (_21967, color(white%1) ciopts(color(white%1)) ) _21968 (_21969, color(white%1) ciopts(color(white%1)) ) (_21970, color(white%1) ciopts(color(white%1)) ) (_21971, color(white%1) ciopts(color(white%1)) ) (_21972, color(white%1) ciopts(color(white%1)) ) (_21973, color(white%1) ciopts(color(white%1)) ) (_21974, color(white%1) ciopts(color(white%1)) ) _21975 (_21976, color(white%1) ciopts(color(white%1)) ) (_21977, color(white%1) ciopts(color(white%1)) ) (_21978, color(white%1) ciopts(color(white%1)) ) (_21979, color(white%1) ciopts(color(white%1)) ) (_21980, color(white%1) ciopts(color(white%1)) ) (_21981, color(white%1) ciopts(color(white%1)) ) _21982 (_21983, color(white%1) ciopts(color(white%1)) ) (_21984, color(white%1) ciopts(color(white%1)) ) (_21985, color(white%1) ciopts(color(white%1)) ) (_21986, color(white%1) ciopts(color(white%1)) ) (_21987, color(white%1) ciopts(color(white%1)) ) (_21988, color(white%1) ciopts(color(white%1)) ) _21989 (_21990, color(white%1) ciopts(color(white%1)) ) (_21991, color(white%1) ciopts(color(white%1)) ) (_21992, color(white%1) ciopts(color(white%1)) ) (_21993, color(white%1) ciopts(color(white%1)) ) (_21994, color(white%1) ciopts(color(white%1)) ) (_21995, color(white%1) ciopts(color(white%1)) ) _21996 (_21997, color(white%1) ciopts(color(white%1)) ) (_21998, color(white%1) ciopts(color(white%1)) ) (_21999, color(white%1) ciopts(color(white%1)) ) (_22000, color(white%1) ciopts(color(white%1)) ) (_22001, color(white%1) ciopts(color(white%1)) ) (_22002, color(white%1) ciopts(color(white%1)) ) _22003 (_22004, color(white%1) ciopts(color(white%1)) ) (_22005, color(white%1) ciopts(color(white%1)) ) (_22006, color(white%1) ciopts(color(white%1)) ) (_22007, color(white%1) ciopts(color(white%1)) ) (_22008, color(white%1) ciopts(color(white%1)) ) (_22009, color(white%1) ciopts(color(white%1)) ) _22010 (_22011, color(white%1) ciopts(color(white%1)) ) (_22012, color(white%1) ciopts(color(white%1)) ) (_22013, color(white%1) ciopts(color(white%1)) ) (_22014, color(white%1) ciopts(color(white%1)) ) (_22015, color(white%1) ciopts(color(white%1)) ) (_22016, color(white%1) ciopts(color(white%1)) ) _22017 (_22018, color(white%1) ciopts(color(white%1)) ) (_22019, color(white%1) ciopts(color(white%1)) ) (_22020, color(white%1) ciopts(color(white%1)) ) (_22021, color(white%1) ciopts(color(white%1)) ) (_22022, color(white%1) ciopts(color(white%1)) ) (_22023, color(white%1) ciopts(color(white%1)) ) _22024 (_22025, color(white%1) ciopts(color(white%1)) ) (_22026, color(white%1) ciopts(color(white%1)) ) (_22027, color(white%1) ciopts(color(white%1)) ) (_22028, color(white%1) ciopts(color(white%1)) ) (_22029, color(white%1) ciopts(color(white%1)) ) (_22030, color(white%1) ciopts(color(white%1)) ) _22031 (_22032, color(white%1) ciopts(color(white%1)) ) (_22033, color(white%1) ciopts(color(white%1)) ) (_22034, color(white%1) ciopts(color(white%1)) ) _22035, $general_options_reduced_p $options $x_line_sf keep(`network') 
			graph export "output/zip_2016_janavg_weekly_`network'_censuscontrols1_`cl'_`pre'`y'.pdf", replace
			}	
		}
	}
}
}
*

* BALANCE CHECKS ON INSTRUMENT (mobility zipcode sample)
* table s1 panel b
global balance_check_mobility=1
if ${balance_check_mobility}==1{
eststo clear	
preserve
foreach var in pop_dens pct_food_stamps pct_occ_serv	landarea pct_nohs  pct_college med_white med_black pct_male {
egen sd_`var'=sd(`var')
replace `var'=`var'/sd_`var'
}
replace fxnc=abs(fxnc)
	foreach fe in county_fips {
		foreach var in fxnc {
		* Checks on Instrument
		eststo:reghdfe age_imb `var' pop_dens   pct_food_stamps landarea pct_nohs  	pct_college med_white med_black pct_male [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		eststo:reghdfe pct_food_stamps `var'  pop_dens age_imb pct_nohs  landarea	pct_college med_white med_black pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		eststo:reghdfe pct_college `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs  med_white med_black pct_male [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		eststo:reghdfe pct_male `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_white med_black   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons

		eststo:reghdfe pct_nohs `var'  pop_dens age_imb pct_food_stamps landarea  pct_college med_white med_black pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		eststo:reghdfe med_black `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_white pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons

		eststo:reghdfe med_white `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_black pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		eststo:reghdfe pop_dens `var'   age_imb pct_food_stamps landarea 	 pct_nohs  pct_college med_white med_black pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons

		eststo:reghdfe landarea  `var'   pop_dens age_imb pct_food_stamps pct_nohs pct_college med_white med_black pct_male   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 
		}
	}
esttab using "output/instrument_balancecheck_zipcodefe.csv", ar2 se replace  star(* 0.05 ** 0.01)	
restore	
}
*

* BALANCE CHECKS ON INSTRUMENT (shopping zipcode sample)
* table s1 panel c
global balance_check_purchases=1
if ${balance_check_purchases}==1{
eststo clear
preserve
foreach var in pop_dens pct_food_stamps pct_occ_serv landarea pct_nohs  pct_college med_white med_black pct_male {
egen sd_`var'=sd(`var')
replace `var'=`var'/sd_`var'
}
replace fxnc=abs(fxnc)
	foreach fe in state_fips  {
		foreach var in fxnc {
		* Checks on Instrument
		cap qui eststo:reghdfe age_imb `var' pop_dens   pct_food_stamps landarea pct_nohs  	pct_college med_white med_black pct_male if zipcode_in_sample==1 [aweight=pop] , absorb(county_fips) cluster(state_fips) nocons

		cap qui eststo:reghdfe pct_food_stamps `var'  pop_dens age_imb pct_nohs  landarea	pct_college med_white med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons

		cap qui eststo:reghdfe pct_college `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs  med_white med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons

		cap qui eststo:reghdfe pct_male `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_white med_black if zipcode_in_sample==1   [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		cap qui eststo:reghdfe pct_nohs `var'  pop_dens age_imb pct_food_stamps landarea  pct_college med_white med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		cap qui eststo:reghdfe med_black `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_white pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		cap qui eststo:reghdfe med_white `var'  pop_dens age_imb pct_food_stamps landarea pct_nohs pct_college med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		cap qui eststo:reghdfe pop_dens `var'   age_imb pct_food_stamps landarea 	 pct_nohs  pct_college med_white med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		reghdfe landarea  `var'   pop_dens age_imb pct_food_stamps pct_nohs pct_college med_white med_black pct_male if zipcode_in_sample==1  [aweight=pop] , absorb(`fe') cluster(state_fips) nocons 

		}
	}
esttab using "output/instrument_balancecheck_zipcode_purchases.csv", ar2 se replace  star(* 0.05 ** 0.01)	
restore
}
*

* SUMMARY STATISTICS (zipcode level)
* table s2
global first_stage=1
if ${first_stage}==1 {
preserve
foreach network in fxnc {
di fxnc[1]
replace `network'=abs(`network')
ivreghdfe tot_expgroc21946 `network' [aweight=pop], absorb(state_fips one##c.($full_controls1 ${other_rtgs_`network'})) cluster(state_fips) first
gen sample_sutex1=1 if e(sample)==1
ivreghdfe sd_sf_dist_fr_home22038 `network' [aweight=pop], absorb(county_fips one##c.($full_controls1 ${other_rtgs_`network'})) cluster(state_fips) first
gen sample_sutex2=1 if e(sample)==1

sutex rtgxxfxnc_2020 rtgxxcnn_2020 rtgxxmsnbc_2020 orig_pos_fxnc_w orig_pos_cnn_w orig_pos_msnbc_w pop pop_dens landarea age_imb pct_food_stamps pct_nohs pct_college med_white med_black pct_male if sample_sutex1==1, minmax
sutex rtgxxfxnc_2020 rtgxxcnn_2020 rtgxxmsnbc_2020 orig_pos_fxnc_w orig_pos_cnn_w orig_pos_msnbc_w pop pop_dens landarea age_imb pct_food_stamps pct_nohs pct_college med_white med_black pct_male if sample_sutex2==1, minmax

restore
}
}
*

* SAFEGRAPH MOBILITY DATA
* figure s8
foreach cl in state_fips {
	foreach network in fxnc {
			foreach y of global outcomes_pick2 {
				cap drop _est*				
					forvalues date=21946/22035 {
					cap qui reghdfe `y'`date' `network' [aweight=pop], absorb(county_fips one##c.($full_controls1)) cluster(`cl')
					cap eststo _`date'
					}
				coefplot $dates_coefplot_mobility_sf, $general_options_reduced $options $x_line_sf keep(`network') 
				graph export "output/zip_nobasefe_2016_`network'_censuscontrols1_`cl'_`y'.pdf", replace
				}	
	*
	}
}
*

* POLYNOMIALS AND INTERACTIONS (balance check controls)	
* figure s9 panel c
global rc_polynomials=1
if ${rc_polynomials}==1 {
foreach check_var in landarea age_imb pct_nohs pct_male {
cap gen `check_var'_2=`check_var'^2	
cap gen `check_var'_3=`check_var'^3	
cap gen `check_var'_fxnc=`check_var'*fxnc
}

global full_controls_var1 "age_imb_2 age_imb_3"
global full_controls_var2 "landarea_2 landarea_3"
global full_controls_var3 "pct_male_2 pct_male_3"
global full_controls_var4 "pct_nohs_2 pct_nohs_3"

foreach cl in state_fips {
			foreach y in sd_tot_expgroc_w_ {
				foreach controls_set in full_controls_var1 full_controls_var2 full_controls_var3 full_controls_var4{				
					forvalues date=21946/22035 {

					cap qui reghdfe `y'`date' fxnc if zipcode_in_sample==1 [aweight=pop], absorb(state_fips one##c.(sd_tot_expgroc_j20 $full_controls1 ${`controls_set'})) cluster(`cl')
					qui lincom _b[fxnc]
					global coef_`controls_set'_`date'=r(estimate)
					global lb_`controls_set'_`date'=r(lb)
					global ub_`controls_set'_`date'=r(ub)
					}
				matrix define matrix_coef_`controls_set'=(${coef_`controls_set'_21946} \ ${coef_`controls_set'_21947} \ ${coef_`controls_set'_21948} \ ${coef_`controls_set'_21949} \ ${coef_`controls_set'_21950} \ ${coef_`controls_set'_21951} \ ${coef_`controls_set'_21952} \ ${coef_`controls_set'_21953} \ ${coef_`controls_set'_21954} \ ${coef_`controls_set'_21955} \ ${coef_`controls_set'_21956} \ ${coef_`controls_set'_21957} \ ${coef_`controls_set'_21958} \ ${coef_`controls_set'_21959} \ ${coef_`controls_set'_21960} \ ${coef_`controls_set'_21961} \ ${coef_`controls_set'_21962} \ ${coef_`controls_set'_21963} \ ${coef_`controls_set'_21964} \ ${coef_`controls_set'_21965} \ ${coef_`controls_set'_21966} \ ${coef_`controls_set'_21967} \ ${coef_`controls_set'_21968} \ ${coef_`controls_set'_21969} \ ${coef_`controls_set'_21970} \ ${coef_`controls_set'_21971} \ ${coef_`controls_set'_21972} \ ${coef_`controls_set'_21973} \ ${coef_`controls_set'_21974} \ ${coef_`controls_set'_21975} \ ${coef_`controls_set'_21976} \ ${coef_`controls_set'_21977} \ ${coef_`controls_set'_21978} \ ${coef_`controls_set'_21979} \ ${coef_`controls_set'_21980} \ ${coef_`controls_set'_21981} \ ${coef_`controls_set'_21982} \ ${coef_`controls_set'_21983} \ ${coef_`controls_set'_21984} \ ${coef_`controls_set'_21985} \ ${coef_`controls_set'_21986} \ ${coef_`controls_set'_21987} \ ${coef_`controls_set'_21988} \ ${coef_`controls_set'_21989} \ ${coef_`controls_set'_21990} \ ${coef_`controls_set'_21991} \ ${coef_`controls_set'_21992} \ ${coef_`controls_set'_21993} \ ${coef_`controls_set'_21994} \ ${coef_`controls_set'_21995} \ ${coef_`controls_set'_21996} \ ${coef_`controls_set'_21997} \ ${coef_`controls_set'_21998} \ ${coef_`controls_set'_21999} \ ${coef_`controls_set'_22000} \ ${coef_`controls_set'_22001} \ ${coef_`controls_set'_22002} \ ${coef_`controls_set'_22003} \ ${coef_`controls_set'_22004} \ ${coef_`controls_set'_22005} \ ${coef_`controls_set'_22006} \ ${coef_`controls_set'_22007} \ ${coef_`controls_set'_22008} \ ${coef_`controls_set'_22009} \ ${coef_`controls_set'_22010} \ ${coef_`controls_set'_22011} \ ${coef_`controls_set'_22012} \ ${coef_`controls_set'_22013} \ ${coef_`controls_set'_22014} \ ${coef_`controls_set'_22015} \ ${coef_`controls_set'_22016} \ ${coef_`controls_set'_22017} \ ${coef_`controls_set'_22018} \ ${coef_`controls_set'_22019} \ ${coef_`controls_set'_22020} \ ${coef_`controls_set'_22021} \ ${coef_`controls_set'_22022} \ ${coef_`controls_set'_22023} \ ${coef_`controls_set'_22024} \ ${coef_`controls_set'_22025} \ ${coef_`controls_set'_22026} \ ${coef_`controls_set'_22027} \ ${coef_`controls_set'_22028} \ ${coef_`controls_set'_22029} \ ${coef_`controls_set'_22030} \ ${coef_`controls_set'_22031} \ ${coef_`controls_set'_22032} \ ${coef_`controls_set'_22033} \ ${coef_`controls_set'_22034} \ ${coef_`controls_set'_22035})
				matrix rownames matrix_coef_`controls_set'= _21946 _21947 _21948 _21949 _21950 _21951 _21952 _21953 _21954 _21955 _21956 _21957 _21958 _21959 _21960 _21961 _21962 _21963 _21964 _21965 _21966 _21967 _21968 _21969 _21970_21971 _21972 _21973 _21974 _21975 _21976 _21977 _21978 _21979 _21980 _21981 _21982 _21983 _21984 _21985 _21986 _21987 _21988 _21989 _21990 _21991 _21992 _21993 _21994 _21995 _21996 _21997 _21998 _21999 _22000 _22001 _22002 _22003 _22004 _22005 _22006 _22007 _22008 _22009 _22010 _22011 _22012 _22013 _22014 _22015 _22016 _22017 _22018 _22019 _22020 _22021 _22022 _22023 _22024 _22025 _22026 _22027 _22028 _22029 _22030 _22031 _22032 _22033 _22034 _22035
				matrix colnames matrix_coef_`controls_set'=b	
				matrix matrix_coef_`controls_set'=matrix_coef_`controls_set''
				
				matrix define matrix_ci_`controls_set'=(${lb_`controls_set'_21946} , ${lb_`controls_set'_21947} , ${lb_`controls_set'_21948} , ${lb_`controls_set'_21949} , ${lb_`controls_set'_21950} , ${lb_`controls_set'_21951} , ${lb_`controls_set'_21952} , ${lb_`controls_set'_21953} , ${lb_`controls_set'_21954} , ${lb_`controls_set'_21955} , ${lb_`controls_set'_21956} , ${lb_`controls_set'_21957} , ${lb_`controls_set'_21958} , ${lb_`controls_set'_21959} , ${lb_`controls_set'_21960} , ${lb_`controls_set'_21961} , ${lb_`controls_set'_21962} , ${lb_`controls_set'_21963} , ${lb_`controls_set'_21964} , ${lb_`controls_set'_21965} , ${lb_`controls_set'_21966} , ${lb_`controls_set'_21967} , ${lb_`controls_set'_21968} , ${lb_`controls_set'_21969} , ${lb_`controls_set'_21970} , ${lb_`controls_set'_21971} , ${lb_`controls_set'_21972} , ${lb_`controls_set'_21973} ,${lb_`controls_set'_21974} , ${lb_`controls_set'_21975} , ${lb_`controls_set'_21976} , ${lb_`controls_set'_21977} , ${lb_`controls_set'_21978} , ${lb_`controls_set'_21979} , ${lb_`controls_set'_21980} , ${lb_`controls_set'_21981} , ${lb_`controls_set'_21982} , ${lb_`controls_set'_21983} , ${lb_`controls_set'_21984} , ${lb_`controls_set'_21985} , ${lb_`controls_set'_21986} , ${lb_`controls_set'_21987} , ${lb_`controls_set'_21988} , ${lb_`controls_set'_21989} , ${lb_`controls_set'_21990} , ${lb_`controls_set'_21991} , ${lb_`controls_set'_21992} , ${lb_`controls_set'_21993} , ${lb_`controls_set'_21994} , ${lb_`controls_set'_21995} , ${lb_`controls_set'_21996} , ${lb_`controls_set'_21997} , ${lb_`controls_set'_21998} , ${lb_`controls_set'_21999} , ${lb_`controls_set'_22000} , ${lb_`controls_set'_22001} , ${lb_`controls_set'_22002} , ${lb_`controls_set'_22003} , ${lb_`controls_set'_22004} , ${lb_`controls_set'_22005} , ${lb_`controls_set'_22006} , ${lb_`controls_set'_22007} , ${lb_`controls_set'_22008} , ${lb_`controls_set'_22009} , ${lb_`controls_set'_22010} , ${lb_`controls_set'_22011} , ${lb_`controls_set'_22012} , ${lb_`controls_set'_22013} , ${lb_`controls_set'_22014} , ${lb_`controls_set'_22015} , ${lb_`controls_set'_22016} , ${lb_`controls_set'_22017} , ${lb_`controls_set'_22018} , ${lb_`controls_set'_22019} , ${lb_`controls_set'_22020} , ${lb_`controls_set'_22021} , ${lb_`controls_set'_22022} , ${lb_`controls_set'_22023} , ${lb_`controls_set'_22024} , ${lb_`controls_set'_22025} , ${lb_`controls_set'_22026} , ${lb_`controls_set'_22027} , ${lb_`controls_set'_22028} , ${lb_`controls_set'_22029} , ${lb_`controls_set'_22030} , ${lb_`controls_set'_22031} , ${lb_`controls_set'_22032} , ${lb_`controls_set'_22033} , ${lb_`controls_set'_22034} , ${lb_`controls_set'_22035} \ ${ub_`controls_set'_21946} , ${ub_`controls_set'_21947} , ${ub_`controls_set'_21948} , ${ub_`controls_set'_21949} , ${ub_`controls_set'_21950} , ${ub_`controls_set'_21951} , ${ub_`controls_set'_21952} , ${ub_`controls_set'_21953} , ${ub_`controls_set'_21954} , ${ub_`controls_set'_21955} , ${ub_`controls_set'_21956} , ${ub_`controls_set'_21957} , ${ub_`controls_set'_21958} , ${ub_`controls_set'_21959} , ${ub_`controls_set'_21960} , ${ub_`controls_set'_21961} , ${ub_`controls_set'_21962} , ${ub_`controls_set'_21963} , ${ub_`controls_set'_21964} , ${ub_`controls_set'_21965} , ${ub_`controls_set'_21966} , ${ub_`controls_set'_21967} , ${ub_`controls_set'_21968} , ${ub_`controls_set'_21969} , ${ub_`controls_set'_21970} , ${ub_`controls_set'_21971} , ${ub_`controls_set'_21972} , ${ub_`controls_set'_21973} ,${ub_`controls_set'_21974} , ${ub_`controls_set'_21975} , ${ub_`controls_set'_21976} , ${ub_`controls_set'_21977} , ${ub_`controls_set'_21978} , ${ub_`controls_set'_21979} ,${ub_`controls_set'_21980} , ${ub_`controls_set'_21981} , ${ub_`controls_set'_21982} , ${ub_`controls_set'_21983} , ${ub_`controls_set'_21984} , ${ub_`controls_set'_21985} , ${ub_`controls_set'_21986} , ${ub_`controls_set'_21987} , ${ub_`controls_set'_21988} , ${ub_`controls_set'_21989} , ${ub_`controls_set'_21990} , ${ub_`controls_set'_21991} , ${ub_`controls_set'_21992} , ${ub_`controls_set'_21993} , ${ub_`controls_set'_21994} , ${ub_`controls_set'_21995} , ${ub_`controls_set'_21996} , ${ub_`controls_set'_21997} , ${ub_`controls_set'_21998} , ${ub_`controls_set'_21999} , ${ub_`controls_set'_22000} , ${ub_`controls_set'_22001} , ${ub_`controls_set'_22002} , ${ub_`controls_set'_22003} , ${ub_`controls_set'_22004} , ${ub_`controls_set'_22005} , ${ub_`controls_set'_22006} , ${ub_`controls_set'_22007} , ${ub_`controls_set'_22008} , ${ub_`controls_set'_22009} , ${ub_`controls_set'_22010} , ${ub_`controls_set'_22011} , ${ub_`controls_set'_22012} , ${ub_`controls_set'_22013} , ${ub_`controls_set'_22014} , ${ub_`controls_set'_22015} , ${ub_`controls_set'_22016} , ${ub_`controls_set'_22017} , ${ub_`controls_set'_22018} , ${ub_`controls_set'_22019} , ${ub_`controls_set'_22020} , ${ub_`controls_set'_22021} , ${ub_`controls_set'_22022} , ${ub_`controls_set'_22023} , ${ub_`controls_set'_22024} , ${ub_`controls_set'_22025} , ${ub_`controls_set'_22026} , ${ub_`controls_set'_22027} , ${ub_`controls_set'_22028} , ${ub_`controls_set'_22029} , ${ub_`controls_set'_22030} , ${ub_`controls_set'_22031} , ${ub_`controls_set'_22032} , ${ub_`controls_set'_22033} , ${ub_`controls_set'_22034} , ${ub_`controls_set'_22035})
				}
			coefplot ///
			(matrix(matrix_coef_full_controls_var1),  ci(matrix_ci_full_controls_var1)  cirecast(rarea) ciopts(color(olive_teal%20)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var2),  ci(matrix_ci_full_controls_var2)  cirecast(rarea) ciopts(color(olive_teal%20)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var3),  ci(matrix_ci_full_controls_var3)  cirecast(rarea) ciopts(color(olive_teal%20)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var4),  ci(matrix_ci_full_controls_var4)  cirecast(rarea) ciopts(color(olive_teal%20)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var1),  ci(matrix_ci_full_controls_var1)  cirecast(rline) ciopts(color(teal) lwidth(vthin)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var2),  ci(matrix_ci_full_controls_var2)  cirecast(rline) ciopts(color(teal) lwidth(vthin)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var3),  ci(matrix_ci_full_controls_var3)  cirecast(rline) ciopts(color(teal) lwidth(vthin)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var4),  ci(matrix_ci_full_controls_var4)  cirecast(rline) ciopts(color(teal) lwidth(vthin)) color(navy%0)) ///
			(matrix(matrix_coef_full_controls_var1),  noci color(maroon) mlwidth(thin)) ///
			(matrix(matrix_coef_full_controls_var2),  noci color(maroon) mlwidth(thin)) ///
			(matrix(matrix_coef_full_controls_var3),  noci color(maroon) mlwidth(thin)) ///
			(matrix(matrix_coef_full_controls_var4),  noci color(maroon) mlwidth(thin)) ///
			, $general_options2 $x_line_multi nooffsets
			graph export "output/zip_janavg_rf_`y'_statefe_polynomials_interactions.pdf", replace
			}
		*
		}
*

}
*

* SHOPPING BY 1996 ELECTIONS PARTISANSHIP
* figure s32
global partisanship=1
if ${partisanship}==1 {
* DECADATA SHOPPING BY PARTISANSHIP
	foreach pre in sd_ {
		foreach cl in state_fips {
			foreach network in fxnc {
			* Main outcomes REDUCED
					foreach y in tot_expgroc  {
						cap drop _est*				
							forvalues date=21946/22035 {
							cap qui reghdfe `pre'`y'_w_`date' `network' if republican_1996==1 [aweight=pop], absorb(state_fips one##c.(sd_`y'_j20 $full_controls1)) cluster(`cl')
							cap eststo _`date'
							}
						macro drop options
						cap coefplot (_21946, color(white%1) ciopts(color(white%1)) ) _21947 (_21948, color(white%1) ciopts(color(white%1)) ) (_21949, color(white%1) ciopts(color(white%1)) ) (_21950, color(white%1) ciopts(color(white%1)) ) (_21951, color(white%1) ciopts(color(white%1)) ) (_21952, color(white%1) ciopts(color(white%1)) ) (_21953, color(white%1) ciopts(color(white%1)) ) _21954 (_21955, color(white%1) ciopts(color(white%1)) ) (_21956, color(white%1) ciopts(color(white%1)) ) (_21957, color(white%1) ciopts(color(white%1)) ) (_21958, color(white%1) ciopts(color(white%1)) ) (_21959, color(white%1) ciopts(color(white%1)) ) (_21960, color(white%1) ciopts(color(white%1)) ) _21961 (_21962, color(white%1) ciopts(color(white%1)) ) (_21963, color(white%1) ciopts(color(white%1)) ) (_21964, color(white%1) ciopts(color(white%1)) ) (_21965, color(white%1) ciopts(color(white%1)) ) (_21966, color(white%1) ciopts(color(white%1)) ) (_21967, color(white%1) ciopts(color(white%1)) ) _21968 (_21969, color(white%1) ciopts(color(white%1)) ) (_21970, color(white%1) ciopts(color(white%1)) ) (_21971, color(white%1) ciopts(color(white%1)) ) (_21972, color(white%1) ciopts(color(white%1)) ) (_21973, color(white%1) ciopts(color(white%1)) ) (_21974, color(white%1) ciopts(color(white%1)) ) _21975 (_21976, color(white%1) ciopts(color(white%1)) ) (_21977, color(white%1) ciopts(color(white%1)) ) (_21978, color(white%1) ciopts(color(white%1)) ) (_21979, color(white%1) ciopts(color(white%1)) ) (_21980, color(white%1) ciopts(color(white%1)) ) (_21981, color(white%1) ciopts(color(white%1)) ) _21982 (_21983, color(white%1) ciopts(color(white%1)) ) (_21984, color(white%1) ciopts(color(white%1)) ) (_21985, color(white%1) ciopts(color(white%1)) ) (_21986, color(white%1) ciopts(color(white%1)) ) (_21987, color(white%1) ciopts(color(white%1)) ) (_21988, color(white%1) ciopts(color(white%1)) ) _21989 (_21990, color(white%1) ciopts(color(white%1)) ) (_21991, color(white%1) ciopts(color(white%1)) ) (_21992, color(white%1) ciopts(color(white%1)) ) (_21993, color(white%1) ciopts(color(white%1)) ) (_21994, color(white%1) ciopts(color(white%1)) ) (_21995, color(white%1) ciopts(color(white%1)) ) _21996 (_21997, color(white%1) ciopts(color(white%1)) ) (_21998, color(white%1) ciopts(color(white%1)) ) (_21999, color(white%1) ciopts(color(white%1)) ) (_22000, color(white%1) ciopts(color(white%1)) ) (_22001, color(white%1) ciopts(color(white%1)) ) (_22002, color(white%1) ciopts(color(white%1)) ) _22003 (_22004, color(white%1) ciopts(color(white%1)) ) (_22005, color(white%1) ciopts(color(white%1)) ) (_22006, color(white%1) ciopts(color(white%1)) ) (_22007, color(white%1) ciopts(color(white%1)) ) (_22008, color(white%1) ciopts(color(white%1)) ) (_22009, color(white%1) ciopts(color(white%1)) ) _22010 (_22011, color(white%1) ciopts(color(white%1)) ) (_22012, color(white%1) ciopts(color(white%1)) ) (_22013, color(white%1) ciopts(color(white%1)) ) (_22014, color(white%1) ciopts(color(white%1)) ) (_22015, color(white%1) ciopts(color(white%1)) ) (_22016, color(white%1) ciopts(color(white%1)) ) _22017 (_22018, color(white%1) ciopts(color(white%1)) ) (_22019, color(white%1) ciopts(color(white%1)) ) (_22020, color(white%1) ciopts(color(white%1)) ) (_22021, color(white%1) ciopts(color(white%1)) ) (_22022, color(white%1) ciopts(color(white%1)) ) (_22023, color(white%1) ciopts(color(white%1)) ) _22024 (_22025, color(white%1) ciopts(color(white%1)) ) (_22026, color(white%1) ciopts(color(white%1)) ) (_22027, color(white%1) ciopts(color(white%1)) ) (_22028, color(white%1) ciopts(color(white%1)) ) (_22029, color(white%1) ciopts(color(white%1)) ) (_22030, color(white%1) ciopts(color(white%1)) ) _22031 (_22032, color(white%1) ciopts(color(white%1)) ) (_22033, color(white%1) ciopts(color(white%1)) ) (_22034, color(white%1) ciopts(color(white%1)) ) _22035, $general_options_reduced_p $options $x_line_sf keep(`network') 
						cap graph export "output/ziprepublican1996_2016_janavg_weekly_`network'_censuscontrols1_`cl'_`pre'`y'.pdf", replace
						}	
			*
			}
		}
	}
*
	foreach pre in sd_ {
		foreach cl in state_fips {
			foreach network in fxnc {
			* Main outcomes REDUCED
					foreach y in tot_expgroc  {
						cap drop _est*				
							forvalues date=21946/22035 {
							cap qui reghdfe `pre'`y'_w_`date' `network' if republican_1996==0 [aweight=pop], absorb(state_fips one##c.(sd_`y'_j20 $full_controls1)) cluster(`cl')
							cap eststo _`date'
							}
						macro drop options
						cap coefplot (_21946, color(white%1) ciopts(color(white%1)) ) _21947 (_21948, color(white%1) ciopts(color(white%1)) ) (_21949, color(white%1) ciopts(color(white%1)) ) (_21950, color(white%1) ciopts(color(white%1)) ) (_21951, color(white%1) ciopts(color(white%1)) ) (_21952, color(white%1) ciopts(color(white%1)) ) (_21953, color(white%1) ciopts(color(white%1)) ) _21954 (_21955, color(white%1) ciopts(color(white%1)) ) (_21956, color(white%1) ciopts(color(white%1)) ) (_21957, color(white%1) ciopts(color(white%1)) ) (_21958, color(white%1) ciopts(color(white%1)) ) (_21959, color(white%1) ciopts(color(white%1)) ) (_21960, color(white%1) ciopts(color(white%1)) ) _21961 (_21962, color(white%1) ciopts(color(white%1)) ) (_21963, color(white%1) ciopts(color(white%1)) ) (_21964, color(white%1) ciopts(color(white%1)) ) (_21965, color(white%1) ciopts(color(white%1)) ) (_21966, color(white%1) ciopts(color(white%1)) ) (_21967, color(white%1) ciopts(color(white%1)) ) _21968 (_21969, color(white%1) ciopts(color(white%1)) ) (_21970, color(white%1) ciopts(color(white%1)) ) (_21971, color(white%1) ciopts(color(white%1)) ) (_21972, color(white%1) ciopts(color(white%1)) ) (_21973, color(white%1) ciopts(color(white%1)) ) (_21974, color(white%1) ciopts(color(white%1)) ) _21975 (_21976, color(white%1) ciopts(color(white%1)) ) (_21977, color(white%1) ciopts(color(white%1)) ) (_21978, color(white%1) ciopts(color(white%1)) ) (_21979, color(white%1) ciopts(color(white%1)) ) (_21980, color(white%1) ciopts(color(white%1)) ) (_21981, color(white%1) ciopts(color(white%1)) ) _21982 (_21983, color(white%1) ciopts(color(white%1)) ) (_21984, color(white%1) ciopts(color(white%1)) ) (_21985, color(white%1) ciopts(color(white%1)) ) (_21986, color(white%1) ciopts(color(white%1)) ) (_21987, color(white%1) ciopts(color(white%1)) ) (_21988, color(white%1) ciopts(color(white%1)) ) _21989 (_21990, color(white%1) ciopts(color(white%1)) ) (_21991, color(white%1) ciopts(color(white%1)) ) (_21992, color(white%1) ciopts(color(white%1)) ) (_21993, color(white%1) ciopts(color(white%1)) ) (_21994, color(white%1) ciopts(color(white%1)) ) (_21995, color(white%1) ciopts(color(white%1)) ) _21996 (_21997, color(white%1) ciopts(color(white%1)) ) (_21998, color(white%1) ciopts(color(white%1)) ) (_21999, color(white%1) ciopts(color(white%1)) ) (_22000, color(white%1) ciopts(color(white%1)) ) (_22001, color(white%1) ciopts(color(white%1)) ) (_22002, color(white%1) ciopts(color(white%1)) ) _22003 (_22004, color(white%1) ciopts(color(white%1)) ) (_22005, color(white%1) ciopts(color(white%1)) ) (_22006, color(white%1) ciopts(color(white%1)) ) (_22007, color(white%1) ciopts(color(white%1)) ) (_22008, color(white%1) ciopts(color(white%1)) ) (_22009, color(white%1) ciopts(color(white%1)) ) _22010 (_22011, color(white%1) ciopts(color(white%1)) ) (_22012, color(white%1) ciopts(color(white%1)) ) (_22013, color(white%1) ciopts(color(white%1)) ) (_22014, color(white%1) ciopts(color(white%1)) ) (_22015, color(white%1) ciopts(color(white%1)) ) (_22016, color(white%1) ciopts(color(white%1)) ) _22017 (_22018, color(white%1) ciopts(color(white%1)) ) (_22019, color(white%1) ciopts(color(white%1)) ) (_22020, color(white%1) ciopts(color(white%1)) ) (_22021, color(white%1) ciopts(color(white%1)) ) (_22022, color(white%1) ciopts(color(white%1)) ) (_22023, color(white%1) ciopts(color(white%1)) ) _22024 (_22025, color(white%1) ciopts(color(white%1)) ) (_22026, color(white%1) ciopts(color(white%1)) ) (_22027, color(white%1) ciopts(color(white%1)) ) (_22028, color(white%1) ciopts(color(white%1)) ) (_22029, color(white%1) ciopts(color(white%1)) ) (_22030, color(white%1) ciopts(color(white%1)) ) _22031 (_22032, color(white%1) ciopts(color(white%1)) ) (_22033, color(white%1) ciopts(color(white%1)) ) (_22034, color(white%1) ciopts(color(white%1)) ) _22035, $general_options_reduced_p $options $x_line_sf keep(`network') 
						cap graph export "output/zipdemocratic1996_2016_janavg_weekly_`network'_censuscontrols1_`cl'_`pre'`y'.pdf", replace
						}	
			*
			}
		}
	}
*
}

* HETEROGENEITY BY DEMOGRAPHICS
* figure s18, figure s20
global heterogeneity=1
if ${heterogeneity}==1 {
*
gen food_stamps=pct_food_stamps
gen nohs=pct_nohs

global dem_touse "food_stamps nohs"

foreach var of global dem_touse {
egen med_`var'=median(pct_`var')
}

foreach var in food_stamps nohs  {
gen  above_med_`var'=pct_`var'>med_`var' if pct_`var'!=.
gen  below_med_`var'=pct_`var'<med_`var' if pct_`var'!=.
}

foreach dem in food_stamps nohs  { 
	foreach pre in sd_ {
		foreach cl in state_fips {
			foreach network in fxnc {
			* Main outcomes REDUCED
					foreach y in tot_expgroc  {
						cap drop _est*				
							forvalues date=21946/22035 {
							cap qui reghdfe `pre'`y'_w_`date' `network' if below_med_`dem'==1 [aweight=pop], absorb(state_fips one##c.(sd_`y'_j20 $full_controls1)) cluster(`cl')
							cap eststo _`date'
							}
						macro drop options
						cap coefplot (_21946, color(white%1) ciopts(color(white%1)) ) _21947 (_21948, color(white%1) ciopts(color(white%1)) ) (_21949, color(white%1) ciopts(color(white%1)) ) (_21950, color(white%1) ciopts(color(white%1)) ) (_21951, color(white%1) ciopts(color(white%1)) ) (_21952, color(white%1) ciopts(color(white%1)) ) (_21953, color(white%1) ciopts(color(white%1)) ) _21954 (_21955, color(white%1) ciopts(color(white%1)) ) (_21956, color(white%1) ciopts(color(white%1)) ) (_21957, color(white%1) ciopts(color(white%1)) ) (_21958, color(white%1) ciopts(color(white%1)) ) (_21959, color(white%1) ciopts(color(white%1)) ) (_21960, color(white%1) ciopts(color(white%1)) ) _21961 (_21962, color(white%1) ciopts(color(white%1)) ) (_21963, color(white%1) ciopts(color(white%1)) ) (_21964, color(white%1) ciopts(color(white%1)) ) (_21965, color(white%1) ciopts(color(white%1)) ) (_21966, color(white%1) ciopts(color(white%1)) ) (_21967, color(white%1) ciopts(color(white%1)) ) _21968 (_21969, color(white%1) ciopts(color(white%1)) ) (_21970, color(white%1) ciopts(color(white%1)) ) (_21971, color(white%1) ciopts(color(white%1)) ) (_21972, color(white%1) ciopts(color(white%1)) ) (_21973, color(white%1) ciopts(color(white%1)) ) (_21974, color(white%1) ciopts(color(white%1)) ) _21975 (_21976, color(white%1) ciopts(color(white%1)) ) (_21977, color(white%1) ciopts(color(white%1)) ) (_21978, color(white%1) ciopts(color(white%1)) ) (_21979, color(white%1) ciopts(color(white%1)) ) (_21980, color(white%1) ciopts(color(white%1)) ) (_21981, color(white%1) ciopts(color(white%1)) ) _21982 (_21983, color(white%1) ciopts(color(white%1)) ) (_21984, color(white%1) ciopts(color(white%1)) ) (_21985, color(white%1) ciopts(color(white%1)) ) (_21986, color(white%1) ciopts(color(white%1)) ) (_21987, color(white%1) ciopts(color(white%1)) ) (_21988, color(white%1) ciopts(color(white%1)) ) _21989 (_21990, color(white%1) ciopts(color(white%1)) ) (_21991, color(white%1) ciopts(color(white%1)) ) (_21992, color(white%1) ciopts(color(white%1)) ) (_21993, color(white%1) ciopts(color(white%1)) ) (_21994, color(white%1) ciopts(color(white%1)) ) (_21995, color(white%1) ciopts(color(white%1)) ) _21996 (_21997, color(white%1) ciopts(color(white%1)) ) (_21998, color(white%1) ciopts(color(white%1)) ) (_21999, color(white%1) ciopts(color(white%1)) ) (_22000, color(white%1) ciopts(color(white%1)) ) (_22001, color(white%1) ciopts(color(white%1)) ) (_22002, color(white%1) ciopts(color(white%1)) ) _22003 (_22004, color(white%1) ciopts(color(white%1)) ) (_22005, color(white%1) ciopts(color(white%1)) ) (_22006, color(white%1) ciopts(color(white%1)) ) (_22007, color(white%1) ciopts(color(white%1)) ) (_22008, color(white%1) ciopts(color(white%1)) ) (_22009, color(white%1) ciopts(color(white%1)) ) _22010 (_22011, color(white%1) ciopts(color(white%1)) ) (_22012, color(white%1) ciopts(color(white%1)) ) (_22013, color(white%1) ciopts(color(white%1)) ) (_22014, color(white%1) ciopts(color(white%1)) ) (_22015, color(white%1) ciopts(color(white%1)) ) (_22016, color(white%1) ciopts(color(white%1)) ) _22017 (_22018, color(white%1) ciopts(color(white%1)) ) (_22019, color(white%1) ciopts(color(white%1)) ) (_22020, color(white%1) ciopts(color(white%1)) ) (_22021, color(white%1) ciopts(color(white%1)) ) (_22022, color(white%1) ciopts(color(white%1)) ) (_22023, color(white%1) ciopts(color(white%1)) ) _22024 (_22025, color(white%1) ciopts(color(white%1)) ) (_22026, color(white%1) ciopts(color(white%1)) ) (_22027, color(white%1) ciopts(color(white%1)) ) (_22028, color(white%1) ciopts(color(white%1)) ) (_22029, color(white%1) ciopts(color(white%1)) ) (_22030, color(white%1) ciopts(color(white%1)) ) _22031 (_22032, color(white%1) ciopts(color(white%1)) ) (_22033, color(white%1) ciopts(color(white%1)) ) (_22034, color(white%1) ciopts(color(white%1)) ) _22035, $general_options_reduced_p $options $x_line_sf keep(`network') 
						graph export "output/zip_below_med_`dem'_2016_janavg_weekly_`network'_censuscontrols1_`cl'_`pre'`y'.pdf", replace
						}	
			*
			}
		}
	}
}
*
foreach dem in food_stamps nohs { 
	foreach pre in sd_ {
		foreach cl in state_fips {
			foreach network in fxnc {
			* Main outcomes REDUCED
					foreach y in tot_expgroc  {
						cap drop _est*				
							forvalues date=21946/22035 {
							qui reghdfe `pre'`y'_w_`date' `network' if above_med_`dem'==1 [aweight=pop], absorb(state_fips one##c.(sd_`y'_j20 $full_controls1)) cluster(`cl')
							cap eststo _`date'
							}
						macro drop options
						cap coefplot (_21946, color(white%1) ciopts(color(white%1)) ) _21947 (_21948, color(white%1) ciopts(color(white%1)) ) (_21949, color(white%1) ciopts(color(white%1)) ) (_21950, color(white%1) ciopts(color(white%1)) ) (_21951, color(white%1) ciopts(color(white%1)) ) (_21952, color(white%1) ciopts(color(white%1)) ) (_21953, color(white%1) ciopts(color(white%1)) ) _21954 (_21955, color(white%1) ciopts(color(white%1)) ) (_21956, color(white%1) ciopts(color(white%1)) ) (_21957, color(white%1) ciopts(color(white%1)) ) (_21958, color(white%1) ciopts(color(white%1)) ) (_21959, color(white%1) ciopts(color(white%1)) ) (_21960, color(white%1) ciopts(color(white%1)) ) _21961 (_21962, color(white%1) ciopts(color(white%1)) ) (_21963, color(white%1) ciopts(color(white%1)) ) (_21964, color(white%1) ciopts(color(white%1)) ) (_21965, color(white%1) ciopts(color(white%1)) ) (_21966, color(white%1) ciopts(color(white%1)) ) (_21967, color(white%1) ciopts(color(white%1)) ) _21968 (_21969, color(white%1) ciopts(color(white%1)) ) (_21970, color(white%1) ciopts(color(white%1)) ) (_21971, color(white%1) ciopts(color(white%1)) ) (_21972, color(white%1) ciopts(color(white%1)) ) (_21973, color(white%1) ciopts(color(white%1)) ) (_21974, color(white%1) ciopts(color(white%1)) ) _21975 (_21976, color(white%1) ciopts(color(white%1)) ) (_21977, color(white%1) ciopts(color(white%1)) ) (_21978, color(white%1) ciopts(color(white%1)) ) (_21979, color(white%1) ciopts(color(white%1)) ) (_21980, color(white%1) ciopts(color(white%1)) ) (_21981, color(white%1) ciopts(color(white%1)) ) _21982 (_21983, color(white%1) ciopts(color(white%1)) ) (_21984, color(white%1) ciopts(color(white%1)) ) (_21985, color(white%1) ciopts(color(white%1)) ) (_21986, color(white%1) ciopts(color(white%1)) ) (_21987, color(white%1) ciopts(color(white%1)) ) (_21988, color(white%1) ciopts(color(white%1)) ) _21989 (_21990, color(white%1) ciopts(color(white%1)) ) (_21991, color(white%1) ciopts(color(white%1)) ) (_21992, color(white%1) ciopts(color(white%1)) ) (_21993, color(white%1) ciopts(color(white%1)) ) (_21994, color(white%1) ciopts(color(white%1)) ) (_21995, color(white%1) ciopts(color(white%1)) ) _21996 (_21997, color(white%1) ciopts(color(white%1)) ) (_21998, color(white%1) ciopts(color(white%1)) ) (_21999, color(white%1) ciopts(color(white%1)) ) (_22000, color(white%1) ciopts(color(white%1)) ) (_22001, color(white%1) ciopts(color(white%1)) ) (_22002, color(white%1) ciopts(color(white%1)) ) _22003 (_22004, color(white%1) ciopts(color(white%1)) ) (_22005, color(white%1) ciopts(color(white%1)) ) (_22006, color(white%1) ciopts(color(white%1)) ) (_22007, color(white%1) ciopts(color(white%1)) ) (_22008, color(white%1) ciopts(color(white%1)) ) (_22009, color(white%1) ciopts(color(white%1)) ) _22010 (_22011, color(white%1) ciopts(color(white%1)) ) (_22012, color(white%1) ciopts(color(white%1)) ) (_22013, color(white%1) ciopts(color(white%1)) ) (_22014, color(white%1) ciopts(color(white%1)) ) (_22015, color(white%1) ciopts(color(white%1)) ) (_22016, color(white%1) ciopts(color(white%1)) ) _22017 (_22018, color(white%1) ciopts(color(white%1)) ) (_22019, color(white%1) ciopts(color(white%1)) ) (_22020, color(white%1) ciopts(color(white%1)) ) (_22021, color(white%1) ciopts(color(white%1)) ) (_22022, color(white%1) ciopts(color(white%1)) ) (_22023, color(white%1) ciopts(color(white%1)) ) _22024 (_22025, color(white%1) ciopts(color(white%1)) ) (_22026, color(white%1) ciopts(color(white%1)) ) (_22027, color(white%1) ciopts(color(white%1)) ) (_22028, color(white%1) ciopts(color(white%1)) ) (_22029, color(white%1) ciopts(color(white%1)) ) (_22030, color(white%1) ciopts(color(white%1)) ) _22031 (_22032, color(white%1) ciopts(color(white%1)) ) (_22033, color(white%1) ciopts(color(white%1)) ) (_22034, color(white%1) ciopts(color(white%1)) ) _22035, $general_options_reduced_p $options $x_line_sf keep(`network') 
						graph export "output/zip_above_med_`dem'_2016_janavg_weekly_`network'_censuscontrols1_`cl'_`pre'`y'.pdf", replace
						}	
			*
			}
		}
	}
}
}
*





